<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@page isELIgnored="false"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Insert title here</title>
	</head>
	<e:View id="view">
		<script type="text/javascript">SkinUtil.getSkin();</script>
		<script type="text/javascript">SkinUtil.getModuleSkin();</script>
		    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_User" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="dataset_user" pageSize="10" loadDataCommand="Command_Load" allowMultiSelect="false">
				<e:Field name="userId" dataType="string" label="用户ID" maxLength="32" />
				<e:Field name="userName" dataType="string" label="用户姓名" maxLength="200" />
				<e:Field name="loginName" dataType="string" label="登录名" maxLength="60" />
				<e:Field name="password" dataType="string" label="密码" maxLength="32" visible="false"/>
				<e:Field name="orgId" dataType="string" label="部门Id" maxLength="32" visible="false"/>
				<e:Field name="roleId" dataType="string" label="角色Id" maxLength="32" visible="false"/>
				<e:Field name="status" dataType="string" label="状态" maxLength="1" dropDown="ListDropDown_Status"/>
				<e:Field name="orgName" dataType="string" label="所属部门" maxLength="100" />
				<e:Field name="roleName" dataType="string" label="所属角色" maxLength="100" />	
				<e:Field name="duty" dataType="string" label="职务" maxLength="32" dropDown="ListDropDown__USER_DUTY"/>
				<e:Field name="sex" dataType="string" label="性别" maxLength="1" dropDown="ListDropDown_sex"/>
				<e:Field name="cardType" dataType="string" label="证件类型" maxLength="32" dropDown="ListDropDown__USER_CARD_TYPE"/>
				<e:Field name="cardNo" dataType="string" label="证件号码" maxLength="32"/>
				<e:Field name="isVirtual" dataType="string" label="是否虚拟柜员" maxLength="1" dropDown="ListDropDown_isVirtual"/>
				<e:Field name="sortNo" dataType="integer" label="序号" maxLength="6" />
				<e:Field name="remark" dataType="string" label="备注" maxLength="200" />											
			</e:Dataset>

							
			<e:Command id="Command_Delete" action="com.longtop.framework.sys.user.web.UserListAction" method="deleteUser" validateRequired="true" 
					onExecuteSuccess="Command_Delete_onExecuteSuccess(command)" showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_User" alwayRefreshClient="false" submitType="changes"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Search" action="com.longtop.framework.sys.user.web.UserListAction" method="searchUser" submitForm="true"  validateRequired="true">
				<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_User" alwayRefreshClient="true" submitType="none"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Load" action="com.longtop.framework.sys.user.web.UserListAction" method="loadUser" showHintInfoOnSuccess="false">
				<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_User" alwayRefreshClient="true"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_export" action="com.longtop.framework.sys.user.web.UserListAction" method="exportUser" submitForm="true" showHintInfoOnSuccess="false">	
			</e:Command>					
			
			<e:ListDropDown id="ListDropDown__USER_DUTY_BIG_CLASS" fixed="true" autoDropDown="false"></e:ListDropDown>
			<e:ListDropDown id="ListDropDown__USER_DUTY" fixed="true" autoDropDown="false"></e:ListDropDown>
			<e:ListDropDown id="ListDropDown__USER_CARD_TYPE" fixed="true" autoDropDown="false"></e:ListDropDown>
			
			<e:ListDropDown id="ListDropDown_sex" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="女" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="男" value="1"></e:ListDropDownItem>
			</e:ListDropDown>			
			<e:ListDropDown id="ListDropDown_isVirtual" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="否" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="是" value="1"></e:ListDropDownItem>
			</e:ListDropDown>
			<e:ListDropDown id="ListDropDown_Status" fixed="true" autoDropDown="true">
				<e:ListDropDownItem name="ListDropDownItem1" label="锁定" value="0"></e:ListDropDownItem>
				<e:ListDropDownItem name="ListDropDownItem2" label="激活" value="1"></e:ListDropDownItem>
			</e:ListDropDown>
			<e:LookupDropDown id="LookupDropDown_Org" path="/jsp/framework/sys/org/orgDropdown.jsp"	windowWidth="600" windowHeight="400" 
				autoDropDown="true" fixed="true" onSelect="LookupDropDown_Org_onSelect(dropdown,iframe,text)" windowCaption="选择机构">
			</e:LookupDropDown>

			<e:Dataset id="Dataset_TeamUser" pageSize="-1">
				<e:Field name="userTeamId" dataType="string" label="员工群组ID" />
				<e:Field name="userTeamName" dataType="string" label="群组名称" />
			</e:Dataset>			 					
			<e:Dataset id="Dataset_TeamOrg" pageSize="-1">
				<e:Field name="orgTeamId" dataType="string" label="机构群组ID" />
				<e:Field name="orgTeamName" dataType="string" label="群组名称" />
			</e:Dataset>			
			<e:DataDropDown dataset="Dataset_TeamUser" id="DataDropDown_TeamUser" autoDropDown="false" fixed="true" showColumnHeader="false"
				codeField="userTeamId" textField="userTeamName" visibleFields="userTeamName" onAfterSelect="DataDropDown_TeamUser_onAfterSelect(dropdown,record,text)">
			</e:DataDropDown>						
			<e:DataDropDown dataset="Dataset_TeamOrg" id="DataDropDown_TeamOrg" autoDropDown="false" fixed="true" showColumnHeader="false"
				codeField="orgTeamId" textField="orgTeamName" visibleFields="orgTeamName" onAfterSelect="DataDropDown_TeamOrg_onAfterSelect(dropdown,record,text)">
			</e:DataDropDown>
						
			<e:LookupDropDown id="LookupDropDown_Duty" path="/jsp/framework/sys/user/dutyDropdown.jsp?showSelect=true"	windowWidth="400" windowHeight="420" 
				autoDropDown="true" fixed="true" onSelect="LookupDropDown_Duty_onSelect(dropdown,iframe,text)" windowCaption="选择职务">
			</e:LookupDropDown>
		</div>
		
		<body>
			<e:Page id="ePage" action="com.longtop.framework.sys.user.web.UserListAction" style="min-height: 80px; width: 100%; height: 100%;" onAfterLoadPage="ePage_onAfterLoadPage()">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" width="100%" align="center">
					<tr>
						<td align="left" valign="top">
							<e:Panel id="Panel_Search" style="width: 285px; height: 100%" caption="查询条件" captionIcon="/images/query_win.gif" captionStyle="color:#888888" allowFold="true"  showArrowButton="false">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
									<tr>
										<td width="80px" align="right">
											<e:Label id="Label_Org" caption="所属机构" />
										</td>
										<td>
											<e:Text id="Text_orgId" style="width: 169px" dropDown="LookupDropDown_Org"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_teamUser" caption="所在员工群组" />
										</td>
										<td>
											<e:Text id="Text_teamUser" style="width: 169px" dropDown="DataDropDown_TeamUser"></e:Text>
										</td>
									</tr>	
									<tr>
										<td align="right">
											<e:Label id="Label_teamOrg" caption="所在机构群组" />
										</td>
										<td>
											<e:Text id="Text_teamOrg" style="width: 169px" dropDown="DataDropDown_TeamOrg"></e:Text>
										</td>
									</tr>									
									<tr>
										<td align="right">
											<e:Label id="Label_id" caption="用户ID"></e:Label>
										</td>
										<td>
											<e:Text id="Text_id" style="width:169px;"></e:Text>
										</td>
									</tr>																		
									<tr>
										<td align="right">
											<e:Label id="Label_LoginName" caption="登陆名"></e:Label>
										</td>
										<td>
											<e:Text id="Text_loginName" style="width:169px;"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_Name" caption="用户姓名"></e:Label>
										</td>
										<td>
											<e:Text id="Text_name" style="width:169px;"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_Status" caption="用户状态" />
										</td>
										<td>
											<e:Text id="Text_status" style="width: 169px" dropDown="ListDropDown_Status"></e:Text>
										</td>
									</tr>
									<tr>
										<td align="right">
											<e:Label id="Label_duty" caption="员工职务" />
										</td>
										<td>
											<e:Text id="Text_duty" style="width: 169px" dropDown="LookupDropDown_Duty"></e:Text>
										</td>
									</tr>									
									<tr>
										<td align="right">
											<e:Label id="Label_isVirtual" caption="是否虚拟柜员" />
										</td>
										<td>
											<e:Text id="Text_isVirtual" style="width: 169px" dropDown="ListDropDown_isVirtual"></e:Text>
										</td>
									</tr>									
									<tr>
										<td></td>
										<td>
											<e:Button id="Button_Search" style='height: 22px; width: 70px' caption="查询" command="Command_Search" icon="/images/query.gif" onClick="Button_Search_onClick()"></e:Button>&nbsp;&nbsp;
											<e:Button id="Button_refush" style='height: 22px; width: 70px' caption="重置" icon="/images/refresh.gif" onClick="Button_refush_onClick()"></e:Button></td>
									</tr>
								</table>
							</e:Panel>
						</td>
						<td valign="top" width="100%">
							<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="查询结果列表" captionIcon="/images/list_win.gif">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" >
									<tr>
										<td>
											<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td height="27px" width="1%">
														<e:RecordNavigator id="RecordNavigator_User" dataset="Dataset_User" showNavigatorButton="false">
															<e:RecordButton id="RecordButton_Insert" label="新增" onClick="RecordButton_Insert_onClick()" icon="/images/add.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_Edit" label="编辑" onClick="RecordButton_Edit_onClick()" icon="/images/edit.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_Delete" label="删除" onClick="RecordButton_Delete_onClick()" icon="/images/delete.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_Export" label="导出EXCEL" command="Command_export" icon="/images/export.gif"></e:RecordButton>
														</e:RecordNavigator>
													</td>
													<td align="left" width="99%"><e:PageNavigator id="PageNavigator_User" dataset="Dataset_User" showRecordNum="true"></e:PageNavigator></td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<e:Grid id="Grid_Index" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_User" readOnly="true" onDblClick="Grid_Result_onDblClick()">
											</e:Grid>
										</td>
									</tr>
								</table>
							</e:Panel>
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
		
		<script type="text/javascript">
			var orgId;
			var orgName;
			//init
			function ePage_onAfterLoadPage(){
				orgId  = $J("Text_orgId").getValue();
				orgName = $J("Text_orgId").getDisplayValue();
			}
			
			//查询
			function Button_Search_onClick(){
			    Command_Search.execute();
			}
			//重置：
			function Button_refush_onClick(){
				$J("Text_loginName").setValue("");
				$J("Text_name").setValue("");
				$J("Text_status").setValue("");
				$J("Text_duty").setValue("");
				$J("Text_teamUser").setValue("");
				$J("Text_teamOrg").setValue("");
				$J("Text_isVirtual").setValue("");
				
				$J("Text_orgId").setValue(orgId,orgName);
			}
			
			//新增
			function RecordButton_Insert_onClick(){
				var path = "/jsp/framework/sys/user/userEdit.jsp?doflag="+"insert";
				openTab("user_insert","新增用户信息",path);
			
			}
			
			//编辑
			function RecordButton_Edit_onClick(){
				var record = Dataset_User.getCurrentRecord();
				if(record){
					var id = record.getValue("userId");
					if(id != null && id != ''){
						var path = "/jsp/framework/sys/user/userEdit.jsp?userId="+id+"&doflag="+"edit";
						openTab("user_edit","编辑用户信息",path);
					}
				}
				
			}
			
			//双击表格查看
			function Grid_Result_onDblClick(){
				RecordButton_Edit_onClick();
			}
			
			//删除
			function RecordButton_Delete_onClick(){
				var record = Dataset_User.getCurrentRecord();
				if(record){
					var id = record.getValue("userId");
					if(id != null && id != ''){
						if(window.confirm("您确定要删除当前选中的用户吗？")){
							Command_Delete.parameters.setValue("userId",id);
							Command_Delete.execute();
						}
					}
				}
			}
			
			//删除成功
			function Command_Delete_onExecuteSuccess(command){
				alert("操作成功！");
				var record = Dataset_User.getCurrentRecord();
				if(record){
					Dataset_User.deleteRecord(record);
				}
			}
			
			//Text选择部门
			function LookupDropDown_Org_onSelect(dropdown,iframe,text){
				var dataset = $J(iframe.Dataset_Org);
				var node = $J(iframe.DataTree_Org).getCurrentNode();
			    var record = dataset.getCurrentRecord();
			    if(typeof record != "undefined" && record != null){
					$J("Text_orgId").setValue(record.getValue("orgId"),record.getValue("orgName"));
				}
			}
			
			//Text选择职务(支持多选)
			function LookupDropDown_Duty_onSelect(dropdown,iframe,text){
				var dataset = $J(iframe.Dataset_Duty);
				var record;
				var dutyIdStr="";
				var dutyNameStr="";					
				var selectedNodes =  $J(iframe.DataTree_Duty).getSelectedNodes();//选中的节点
				if(selectedNodes == null){// 单选
					record = dataset.getCurrentRecord();
					var dutyId ="'"+record.getValue("dutyId")+"'";
					var dutyName= record.getValue("dutyName");						
					$J("Text_duty").setValue(dutyId,dutyName);//组装DutyList
				}else{
					for(var i=0; i<selectedNodes.length; i++) {
					   record = selectedNodes[i].record;
					   if (record) {
							var dutyId ="'"+record.getValue("dutyId")+"',";
							var dutyName= record.getValue("dutyName")+",";
							dutyIdStr = dutyIdStr+dutyId;		
							dutyNameStr = dutyNameStr+dutyName;						       
					   }
					}	
					dutyIdStr = dutyIdStr.substr(0,dutyIdStr.length-1);
					dutyNameStr = dutyNameStr.substr(0,dutyNameStr.length-1);								
				    $J("Text_duty").setValue(dutyIdStr,dutyNameStr);//组装DutyList
			 	}
			}			
		</script>
		
	</e:View>
</html>
